clear all
set more off
capture log close
log using "$output/figure2.log", replace

version 16	

use "$data/ctcbyincome.dta", clear

twoway line totctc year if depx==1 & earnings==10000, pstyle(p1) lp(-) || line totctc year if depx==2 & earnings==10000, pstyle(p2) lp(_) || line totctc year if depx==3 & earnings==10000, pstyle(p3) graphregion(color(white)) bgcolor(white) leg(order(1 "1 Kid" 2 "2 Kids" 3 "3 Kids") c(1) pos(10) ring(0)) ytitle("Total CTC Benefits") xtitle("Year" "{bf:Panel A: Earnings = $10,000}") ylabel(0(3000)9000) text(7500 2013 "Earnings = $10,000" , j(left) size(medsmall))
graph save "$output/ctc10k.gph", replace


twoway line totctc year if depx==1 & earnings==20000, pstyle(p1) lp(-) || line totctc year if depx==2 & earnings==20000, pstyle(p2) lp(_) || line totctc year if depx==3 & earnings==20000, pstyle(p3) graphregion(color(white)) bgcolor(white) leg(order(1 "1 Kid" 2 "2 Kids" 3 "3 Kids") c(1) pos(10) ring(0)) ytitle("Total CTC Benefits") xtitle("Year" "{bf:Panel B: Earnings = $20,000}") ylabel(0(3000)9000) text(7500 2013 "Earnings = $20,000" , j(left) size(medsmall))
graph save "$output/ctc20k.gph", replace


twoway line totctc year if depx==1 & earnings==30000, pstyle(p1) lp(-) || line totctc year if depx==2 & earnings==30000, pstyle(p2) lp(_) || line totctc year if depx==3 & earnings==30000, pstyle(p3) graphregion(color(white)) bgcolor(white) leg(order(1 "1 Kid" 2 "2 Kids" 3 "3 Kids") c(1) pos(10) ring(0)) ytitle("Total CTC Benefits") xtitle("Year" "{bf:Panel C: Earnings = $30,000}") ylabel(0(3000)9000) text(7500 2013 "Earnings = $30,000" , j(left) size(medsmall))
graph save "$output/ctc30k.gph", replace


twoway line totctc year if depx==1 & earnings==50000, pstyle(p1) lp(-) || line totctc year if depx==2 & earnings==50000, pstyle(p2) lp(_) || line totctc year if depx==3 & earnings==50000, pstyle(p3) graphregion(color(white)) bgcolor(white) leg(order(1 "1 Kid" 2 "2 Kids" 3 "3 Kids") c(1) pos(10) ring(0)) ytitle("Total CTC Benefits") xtitle("Year" "{bf:Panel D: Earnings = $50,000}") ylabel(0(3000)9000) text(7500 2013 "Earnings = $50,000" , j(left) size(medsmall))
graph save "$output/ctc50k.gph", replace


graph combine "$output/ctc10k.gph" "$output/ctc20k.gph" "$output/ctc30k.gph" "$output/ctc50k.gph" ,graphregion(color(white)) 
graph export "$output/figure2.png", replace

erase "$output/ctc10k.gph" 
erase "$output/ctc20k.gph" 
erase "$output/ctc30k.gph" 
erase "$output/ctc50k.gph"

log close